<?php

namespace App\Http\Controllers;

use App\Models\Tag;
use Illuminate\Http\Request;

class TagsController extends Controller
{

    public function show(Request $request, Tag $tag)
    {
        // 读取分类 ID 关联的话题，并按每 20 条分页
        $topics = $tag->topics()
            ->with('category', 'user', 'tags')
            ->where('publish',true)
            ->withOrder($request->order)
            ->paginate(20);
        // 传参变量话题和分类到模板中
        return view('topics.index', compact('topics', 'tag'));
    }


}
